/**
 * Created by yeso on 2015/9/24.
 */
angular.module('app.service.goods', ['ngResource'])

//good
    .service('GoodService', ['$resource', function ($resource) {
        var goodsres = $resource(localhost + "goods/:goodid");
        //增加good
        this.addgood = function (good, success, error) {
            return goodsres.save({}, good, success, error);
        }
        //通过id,获取good
        this.getgoodbyid = function (id) {
            return goodsres.get({goodid: id});
        }
        //通过id,删除good
        this.removegoodbyid = function (id) {
            return goodsres.remove({goodid: id});
        }
        
        //通过name,获取good
        this.getgoodbyname = function (name) {
            var resource = $resource(localhost + "goods/byname/:name");
            return resource.get({name: name});
        }
        //通过商店编号,获取商品列表
        this.getshopgoodslist = function (shopid) {
            var resource = $resource(localhost + "goods/byshopid/:shopid");
            return resource.query({shopid: shopid});
        }

    }])
;